library(tidyverse)
library(readxl)
path <- "2025-12-21/Challenge 87.xlsx"
input <- read_excel(path, range = "B2:B8")
test <- read_excel(path, range = "D2:D8")
result = input %>%
mutate(extracted = str_extract(Address, "(?<=\\d{5} )[^,]+"))
all.equal(result$extracted, test$City)
# [1] TRUECrispo - Excel Challenge 51 2025
excel-challenges
weekly-exercises
Easy Sunday Excel Challenge

Challenge Description
Easy Sunday Excel Challenge
⭐ ⭐Extract the City Name i.e. name after the 5 digit postal code
Solutions
Logic:
Reads the workbook range needed for the challenge
Builds the intermediate helper columns that drive the final answer
Uses direct text-pattern extraction instead of manual cleanup
Strengths:
- The R solution stays compact and mirrors the workbook logic closely.
Areas for Improvement:
- The code assumes the workbook layout and named ranges remain stable.
Gem:
- The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd
import re
path = "2025-12-21/Challenge 87.xlsx"
input = pd.read_excel(path, usecols="B", skiprows=1, nrows=6)
test = pd.read_excel(path, usecols="D", skiprows=1, nrows=6)
def extract_city(address):
match = re.search(r"(?<=\d{5} )[^,]+", str(address))
return match.group(0) if match else None
input['extracted'] = input.iloc[:, 0].apply(extract_city)
print(input['extracted'].equals(test['City'])) # TrueLogic:
Reads the workbook range needed for the challenge
Uses direct text-pattern extraction instead of manual cleanup
Strengths:
- The Python version keeps the same rule in a direct pandas-oriented workflow.
Areas for Improvement:
- As with the R version, any workbook layout change would require small adjustments.
Gem:
- The implementation stays close to the stated challenge instead of adding unnecessary complexity.
Difficulty Level
This task is moderate:
It combines familiar Excel-style logic with at least one non-trivial reshape, grouping, or parsing step.
The answer depends on getting the output layout exactly right.